From 5a90c75aa7c3723aa07ae8bc825a662ca8ba4a23 Mon Sep 17 00:00:00 2001 From: oliskoli Date: Thu, 30 Nov 2006 01:32:41 +0000 Subject: [PATCH] Do not read empty files. --- mapsend.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mapsend.c b/mapsend.c index 90cb6aa63..89629d1ba 100644 --- a/mapsend.c +++ b/mapsend.c @@ -313,7 +313,7 @@ static void mapsend_read(void) { mapsend_hdr hdr; - int type; + int type, len; char buf[3]; /* @@ -321,7 +321,9 @@ mapsend_read(void) * strings, each member has to be read in one at a time. Grrr. */ - fread(&hdr, sizeof(hdr), 1, mapsend_file_in); + len = fread(&hdr, 1, sizeof(hdr), mapsend_file_in); + is_fatal(len < sizeof(hdr), MYNAME ": No mapsend or empty file!"); + type = le_read16(&hdr.ms_type); strncpy(buf, hdr.ms_version, 2); buf[2] = '\0'; -- 2.30.2